package it.tava.andbudget.data;

import it.tava.andbudget.data.parser.ParserFactory;
import it.tava.andbudget.data.parser.ParserInterface;
import it.tava.andbudget.data.resource.Charge;
import it.tava.andbudget.data.resource.ResourceManager;

import org.xmlpull.v1.XmlPullParser;

public class XmlManager implements DataManager {
	
	private ParserInterface parser;
	private ResourceManager manager;
	
	
	public XmlManager(XmlPullParser parser) {
		this.parser = ParserFactory.makeParser(parser);
	}
	
	/*
	 * Using lazy initialization method
	 */
	private void loadData() {
		if(manager == null) {
			manager = parser.parse();
		}
	}

	@Override
	public long addCharge(Charge charge) {
		loadData();
		return 0;
	}

	@Override
	public void close() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Charge getCharge(long id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean updateCharge(long id, Charge charge) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void open() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean removeCharge(long id) {
		// TODO Auto-generated method stub
		return false;
	}
}
